package com.deli.springboot.quartz.sendMessage;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.scheduling.annotation.Scheduled;

public class SendMeassageScheduler {
    public static void main(String[] args) throws SchedulerException, InterruptedException {

        JobDetail jobDetail = JobBuilder.newJob(SendMessageJob.class)
                .withIdentity("sendMessageJob", "quartz").build();


        Trigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("sendMessageTrigger", "quartz")
                .withSchedule(CronScheduleBuilder.cronSchedule("0/2 * * * * ?")).build();//每天10点发送

        SchedulerFactory factory = new StdSchedulerFactory();
        Scheduler scheduler = factory.getScheduler();
        scheduler.start();
        scheduler.scheduleJob(jobDetail, trigger);
    }
}
